package com.owner.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.owner.biz.UserBiz;
import com.owner.entity.Plots;
import com.owner.entity.Role;
import com.owner.entity.User;

@Controller
public class RegisterContoller {

	@Autowired
	private UserBiz userbiz;
	
	@RequestMapping("/showregister")
	public String showregister(){
		
		return "register";
	}
	@RequestMapping("/register")
	public String register(String nickName,String password,String city,String district,String villageName,String managePhone,String safePhone,String email){
		User user =new User();
		user.setNickName(nickName);
		user.setPassword(password);
		user.setEmail(email);
		userbiz.addUser(user);
		
		Plots plots =new Plots();
		String urban = city +district;//地址
		System.out.println(urban);
		plots.setName(villageName);
		plots.setImage("4.jpg");
		plots.setAddress(urban);
		plots.setManagePhone(managePhone);
		plots.setSafePhone(safePhone);
		plots.setEmail(email);
		plots.setStatus("未审核");
		userbiz.addPlots(plots);
		
		return "login";
	}
}
